﻿using System;
using YTE.Control;
using 右下角弹窗.DiagShow;

namespace LD.Host
{
    public partial class FrmPartNoEdit : FrmOKCancel
    {

        public FrmPartNoEdit()
        {
            InitializeComponent();
            this.Shown += FrmFlowEdit_Shown;
            this.btn_ok.Click += Btn_ok_Click;
        }
        public FrmPartNoEdit(string name) : this()
        {

        }
        private void FrmFlowEdit_Shown(object sender, EventArgs e)
        {
            if (PartNo != null)
            {
                this.txt_id.Text = PartNo.Id + "";
                this.txt_name.Text = PartNo.Name;
            }
        }

        private void Btn_ok_Click(object sender, EventArgs e)
        {
            if (!int.TryParse(this.txt_id.Text, out var id))
            {
                Dialog dialog = new Dialog();
                dialog.Warning("机种Id必须为整数");
                return;
            }
            PartNo = new TB_PartNo();
            PartNo.Id = id;
            PartNo.Name = this.txt_name.Text;
            this.Close();
        }
        public TB_PartNo PartNo { get; set; }

    }
}
